﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;

using KCL.Code.Data;

namespace KCL.Code.Business
{
    public class MaterialExportServices
    {
        public static MaterialExport GetMaterialExportByID(int id)
        {
            return (new MaterialExportDAO()).GetMaterialExportByID(id);
        }

        public static List<MaterialExport> GetAllMaterialExports()
        {
            return (new MaterialExportDAO()).GetAllMaterialExports();
        }

        public static bool Insert(MaterialExport me)
        {
            MaterialExportDAO mexpDAO = new MaterialExportDAO();
            me.id = mexpDAO.GetMaxID() + 1;
            if (mexpDAO.Insert(me))
            {
                (new MaterialDAO()).UpdateMaterialQuantity(me.materialCode);
                return true;
            }
            return false;
        }

        public static bool Update(MaterialExport me)
        {
            if ((new MaterialExportDAO()).Update(me))
            {
                (new MaterialDAO()).UpdateMaterialQuantity(me.materialCode);
                return true;
            }
            return false;
        }

        public static bool Delete(MaterialExport me)
        {
            if ((new MaterialExportDAO()).Delete(me))
            {
                (new MaterialDAO()).UpdateMaterialQuantity(me.materialCode);
                return true;
            }
            return false;
        }
    }
}